home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
superv22.zip
/
EXEC.DOC
< prev
next >
Wrap
Text File
|
1986-12-02
|
4KB
|
98 lines
Execute other programs from Turbo Pascal
Written/Compiled by
Doctor Debug
This will give a brief description of the functions included
with EXEC.INC. It allows the Turbo programmer to call other
applications from within a pascal program which has been compiled
to a COM file. None of these will work in the Turbo environment.
One word of warning - you must leave some memory for the
other applications. You can do this by specifying the Maximum
Free Dynamic Memory to be less than all the rest of the machine's
memory, which is what Turbo defaults to. I have found that
setting this to $1000 (4096 bytes) is usually sufficient unless
your program does a great deal of heap operations or recursion.
I suggest that you do what I do, that is, play with the numbers
until you achieve a happy medium. If you reserve too little
memory for other applications, the result of an Exec, Shell, or
ExecCommand will be an 8, which indicates not enough memory. If
you allocate too little memory for your Turbo program's heap, you
will get a 'Stack-Heap collision' error from Turbo.
In general, everything you pass to these functions should be
a string of type String[255], and the functions will return an
integer error code. A zero return code means that the function
was completed successfully. Any other value is the DOS error
code:
Code Meaning
2 File not Found
3 Path not Found
4 Too Many Open Files
5 Access Denied
7 Control Blocks Destroyed (Reboot!!!)
8 Insufficient Memory
If any other code returns, consult the DOS Technical
Reference manual's list of Function error codes.
Function Exec(Command: Exec_Str255): Integer;
This function executes the passed command, but the full
filename (including the extension) must be included and the
program must exist on the current directory. PATH or SEARCH will
not help you here.
Function ExecCommand(Command: Exec_Str255): Integer;
This function loads a new copy of COMMAND.COM and then
passes your Command String to it. This is the preferred way of
executing an application, because you can format the command
string just as you would type it into the system and also PATH
and SEARCH will work just fine, meaning that the file doesn't
necessarily have to be in the same directory as your program. The
only drawback is that another copy of Command.Com takes up a
little memory. Another consideration is that programs Executed in
this way load just a little slower.
COMMAND.COM does not have to exist on the same directory as
the program, for ExecCommand looks at the COMSPEC environment
parameter and finds COMMAND.COM wherever the system booted from.
Remember this if you run your program from a floppy based system
- COMMAND.COM has to exist SOMEWHERE!
Function Shell: Integer;
This is a special case of ExecCommand which will give the
user a DOS prompt and let him dally to his heart's content. Your
Turbo program will not regain control until the user types EXIT
from the DOS prompt.
The following two functions are used internally to find the
COMSPEC parameter, but you may want to use them in your programs
also:
Function GetEnvString(Command: Exec_Str255): Exec_Str255;
Pass this function an Environment label (i.e. COMSPEC, PATH,
etc) and if that label is defined in the current environment the
setting for that label will be returned. An empty string will be
returned if that item does not exist. Make sure you pass the
Environment Parameter as CAPITALS.
Function ComSpec: Exec_Str255;
Using the above function, this function returns the current
drive, path and name of the COMMAND.COM used by DOS. This is very
handy information.
All of these functions have been extensively tested and
should work fine. If you have any problems, questions, or
suggestions you can reach me at the NeverBoard Fido BBS, (412)
733-4842.
Good Day from Doctor Debug.